package com.dinadi.yidi.http.interfaces;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.dinadi.yidi.bean.UpdateHeadImgBean;
import com.dinadi.yidi.http.BaseInterface;
import com.dinadi.yidi.http.HttpListener;
import com.dinadi.yidi.http.HttpUrl;
import com.dinadi.yidi.http.ServiceUtil;
import com.dinadi.yidi.utils.algorithms.DesUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * author: JiaYu.He
 * Date: 2017/3/30    上传头像  不需要加密
 * Time: 16:29
 */

public class UpdateHeadImgInterface extends BaseInterface {
    public UpdateHeadImgInterface(Context context, HttpListener listener) {
        super(context, listener);
    }

    public void getInterface(final String transcode, final UpdateHeadImgBean content) {
        //参数
        Map<String, String> param = new HashMap<>();
        param.put("transcode", transcode);
        try {
            param.put("content", JSON.toJSONString(content));
        } catch (Exception e) {
            e.printStackTrace();
        }
        ServiceUtil.requestPostData(HttpUrl.serverHost, param, new ServiceUtil.RequestCallBack<String>() {
            @Override
            public void onSuccess(String result) {
                try {
                    listener.OnSuccess(DesUtil.decrypt(result));
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onFailure(String error) {
                listener.OnFail(error);

            }
        });

    }


}
